1. Field of the Invention
This invention relates to the field of image data compression, and in particular color value compression in multi-sampled anti-aliasing applications.
2. Discussion of Related Art
Three dimensional graphics processing applications require the storage and processing of large amounts of data. In particular, color information takes up a large amount of memory. In addition, the time it takes to transfer color data from memory to a graphics processor can negatively affect the ability to process graphics data. There is a need to reduce the amount of memory needed to store graphics data and to improve the ability to quickly transfer graphics data from memory to processor. This problem can be understood by reviewing the way that graphics systems process data.
Computer systems are often used to generate and display graphics on a display. Display images are made up of thousands of tiny dots, where each dot is one of thousands or millions of colors. These dots are known as picture elements, or “pixels”. Each pixel has a color, with the color of each pixel being represented by a number value stored in the computer system.
A three dimensional display image, although displayed using a two dimensional array of pixels, may in fact be created by rendering a plurality of graphical objects. Examples of graphical objects include points, lines, polygons, and three dimensional solid objects. Points, lines, and polygons represent rendering “primitives” which are the basis for most rendering instructions. More complex structures, such as three dimensional objects, are formed from a combination or mesh of such primitives. To display a particular scene, the visible primitives associated with the scene are drawn individually by determining those pixels that fall within the edges of the primitive, and obtaining the attributes of the primitive that correspond to each of those pixels. The obtained attributes are used to determine the displayed color values of applicable pixels.
Sometimes, a three dimensional display image is formed from overlapping primitives or surfaces. A blending function based on an opacity value associated with each pixel of each primitive is used to blend the colors of overlapping surfaces or layers when the top surface is not completely opaque. The final displayed color of an individual pixel may thus be a blend of colors from multiple surfaces or layers.
Aliasing
A phenomenon termed, “aliasing” frequently occurs at the border between two overlapping primitives or surfaces. In aliasing, straight lines are displayed such that a stair step effect develops. Pixels are not mathematical points which are either on or off a line. Instead, pixels have a finite width, and, typically, a pixel is considered on a line if the line passes through the pixel's area.
FIG. 1 illustrates an example of aliasing. Edge 1 of a polygon (100) passes through pixels 5, (125), 6 (130), 7 (135), 8 (140), and 9 (145). Thus, polygon 100 covers pixels 5, 6, 7, 8, and 9. These pixels are shaded and pixels 1 (105), 2 (110), 3 (115), and 4 (120) are not shaded. The resulting display looks like a jagged stair step rather than a line.
Anti-Aliasing
One anti-aliasing technique adjusts pixel colors where aliasing occurs in an attempt to smooth the display. For example, a pixel's intensity may depend on the length of the line segment that falls in the pixel's area.
FIG. 2A illustrates an example of anti-aliasing. Edge 1 (200) of a polygon passes through pixels 5, (225), 6 (230), 7 (235), 8 (240), and 9 (245). However, the edge passes through a small portion of pixel 5, so the intensity of the pixel is low. The intensity of pixel 8 is higher because more of the edge passes through pixel 8. Pixel 9 is completely within the polygon, thus it has the darkest shade. Likewise, the intensities of pixels 6 and 7 are also higher. Pixels 1 (205), 2 (210), 3 (215), and 4 (220) are not shaded because the edge does not pass through them. These pixels lie outside of polygon 200. With the intensity adjusted per the amount of pixel lying within the polygon, the resulting edge on the display is smoother than the aliased edge.
Multi-sampling is another anti-aliasing technique for determining the color of a pixel. Each pixel is divided into sub-pixels, or samples. A color is determined for each sample, and the sample colors are combined to yield a color for the entire pixel. For example, suppose that each pixel in FIG. 2A is further divided into four samples. Then each sample would cover ¼ of the area of the original pixel, as shown in FIG. 2B. Thus pixel 6 (220) would be of a darker color because two of its samples are covered by the intersecting edge. In contrast, pixel 5 (225) would be of a light color because only one of its samples is covered by the intersecting edge. Thus in simplified terms, pixel 6 (230) may have 50% color contribution from the dark color from polygon 200 and 50% color contribution from the clear background. Thus its final color would be of a 50% shading. Pixel 5 (225) may have 25% color contribution from the dark color from polygon 200 and 75% color contribution from the clear background. Thus its final color would be of a 25% shading. It must be noted this is an illustration only and in practice, the number of samples do vary and the granularity depicted in the figures are not to proportion to the actual thickness of the lines and pixels. Also, it can be seen that the more samples a system employs, the better the anti-aliasing can become. However, the demand on system resources increases in proportion to the number of samples.
Rendering
In some cases, graphical data is rendered by executing instructions from an application that is drawing data to a display. During image rendering, three dimensional data is processed into a two dimensional image suitable for display. The three dimensional image data represents attributes such as color, opacity, texture, depth, and perspective information. The draw commands from a program drawing to the display may include, for example, X and Y coordinates for the vertices of the primitive, as well as some attribute parameters for the primitive, and a drawing command. Examples of attribute parameters for primitives include color and depth, or “Z” data. Three-dimensional data includes not only horizontal and vertical components on an X and Y axis, but also include a depth component along an axis labeled Z. The execution of drawing commands to generate a display image is known as graphics processing.
Three-dimensional data processing is very data intensive. The color data for a pixel is typically 24 or 32 bits. For a megapixel display, large amounts of storage are required just to store the data to be displayed. Compression schemes are needed to reduce the amount of data transferred between the memory and the processor to improve performance.